<?php

function customError($errno, $errstr, $errfile, $errline) {
    $array = array();
    $array['errno'] = $errno;
    $array['errstr'] = $errstr;
    $array['errfile'] = $errfile;
    $array['errline'] = $errline;
    $iscli = (php_sapi_name() == 'cli') ? 1 : 0;
    if (!$iscli) {
        echo '<pre>';
    }
    print_r($array);
    if (!$iscli) {
        echo '</pre>';
    }
    if ($errno == 2) {
        //非代码错误
    } else {
        die();
    }
}

set_error_handler("customError"); //过滤错误
define('__DS__', DIRECTORY_SEPARATOR); //定义目录分割符
// Strip magic quotes from request data.
if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) {
    // Create lamba style unescaping function (for portability)
    $quotes_sybase = strtolower(ini_get('magic_quotes_sybase'));
    $unescape_function = (empty($quotes_sybase) || $quotes_sybase === 'off') ? 'stripslashes($value)' : 'str_replace("\'\'","\'",$value)';
    $stripslashes_deep = create_function('&$value, $fn', '
        if (is_string($value)) {
            $value = ' . $unescape_function . ';
        } else if (is_array($value)) {
            foreach ($value as &$v) $fn($v, $fn);
        }
    ');
    // Unescape data
    $stripslashes_deep($_POST, $stripslashes_deep);
    $stripslashes_deep($_GET, $stripslashes_deep);
    $stripslashes_deep($_COOKIE, $stripslashes_deep);
    $stripslashes_deep($_REQUEST, $stripslashes_deep);
}
$GLOBALS['SYSTIME'] = microtime(true); //获取系统时间
$GLOBALS['USERIPV4'] = isset($_SERVER["HTTP_X_FORWARDED_FOR"]) ? $_SERVER["HTTP_X_FORWARDED_FOR"] : (isset($_SERVER["REMOTE_ADDR"]) ? $_SERVER["REMOTE_ADDR"] : '');
header('P3P: CP="CAO DSP COR CUR ADM DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE GOV"'); //p3p
header('Content-Type: text/html; charset=utf-8');
date_default_timezone_set('PRC'); //设置为中国时间
